package cms.student.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import cms.student.entity.Area;
import cms.student.entity.Student;
import cms.student.entity.Subject;

public interface StudentMapper {

	List<Student> list(String name);

	@Select("SELECT id,name FROM stu_area WHERE parentId=#{value}")
	List<Area> listAreasByParentId(int parentId);

	@Select("SELECT id,name FROM stu_subject ")
	List<Subject> listAllSubjects();

	void add(Student stu);

	@Insert("INSERT INTO stu_student_subject(student_id,subject_id) " + "VALUES(#{stuId},#{subId}) ")
	void addStuSub(@Param("stuId") Integer stuId, @Param("subId") int subId);

	Student getById(int id);

	@Update("UPDATE stu_students SET name=#{name} ,enter_date=#{enterDate} ,province_id=#{provinceId}"
			+ ", city_id=#{cityId} , county_id=#{countyId} WHERE id=#{id}")
	void update(Student stu);

	@Delete("DELETE FROM stu_student_subject WHERE student_id=#{value}")
	void delSubjectId(int id);

	void delBathSubjectIds(int[] ids);

	void delBath(int[] ids);

	List<Student> listBySub(@Param("name") String name, @Param("selSubId") int[] selSubId);
}
